#include <chrono>
#include <jsoncpp/json/value.h>
#include <memory>
#include <thread>



#include "../client/rpc_client.hpp"
#include "../common/detail.hpp"
#include <thread>
using namespace rpc;

void callback(const std::string &key, const std::string &msg)
{
    ILOG("%s 主题收到推送过来的消息: %s", key.c_str(), msg.c_str());
}

int main()
{
    //实例化订阅客户端
    auto client = std::make_shared<rpc::client::TopicClient>("127.0.0.1", 8080);
    //创建主题
    bool ret = client->create("hello");
    if(!ret)
    {
        ELOG("创建主题失败");
    }
    ret = client->subscribe("hello", callback);
    //等待-退出
    std::this_thread::sleep_for(std::chrono::seconds(10));
    client->shutdown();
    return 0;
}